import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ThrottlerModule } from '@nestjs/throttler';
import { WebsocketGateway } from './websocket.gateway';
import { WebsocketService } from './websocket.service';
import { RoomsModule } from '../rooms/rooms.module';
import { RedisModule } from '../redis/redis.module';

@Module({
  imports: [
    ConfigModule,
    RoomsModule,
    RedisModule,
    ThrottlerModule.forRoot([
      {
        name: 'websocket-short',
        ttl: 1000, // 1秒
        limit: 10, // 10次请求
      },
      {
        name: 'websocket-medium',
        ttl: 10000, // 10秒
        limit: 50, // 50次请求
      },
      {
        name: 'websocket-long',
        ttl: 60000, // 1分钟
        limit: 200, // 200次请求
      },
    ]),
  ],
  providers: [WebsocketGateway, WebsocketService],
  exports: [WebsocketGateway, WebsocketService],
})
export class WebsocketModule {}
